package per.dj.testpro.entity.protocol;


import per.dj.testpro.utils.common.ClassUtils;
import per.dj.testpro.utils.common.Tools;

public final class MessageFactory
{
    public static IMessageBody Create(int messageType, byte[] messageBodyBytes)
    {

        String nameSpace = MessageFactory.class.getPackage().getName();
        String className = nameSpace + ".Qy_" + Tools.ToHexString(messageType,1).toUpperCase();

        Object messageBody = ClassUtils.getBean(className);
        if (messageBody != null)
        {
            IMessageBody msg = (IMessageBody)messageBody;
            msg.ReadFromBytes(messageBodyBytes);
            return msg;
        }
        return null;
    }

}